Skip to content

Commit

Permalink
BAGEL: Add some missing const, remove some unused code, rename a coup…
Browse files Browse the repository at this point in the history
…le of functions
  • Loading branch information
Strangerke committed May 15, 2024
1 parent 938d267 commit a8f77dd
Show file tree
Hide file tree
Showing 25 changed files with 69 additions and 98 deletions.
4 changes: 2 additions & 2 deletions engines/bagel/baglib/area_object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ CBofSize CBagAreaObject::getSize() const {
CBagAreaObject::CBagAreaObject() {
_xObjType = AREA_OBJ;
setVisible(false);
setOverCursor(4);
CBagObject::setOverCursor(4);
}

CBagAreaObject::~CBagAreaObject() {
detach();
CBagAreaObject::detach();
}

ErrorCode CBagAreaObject::attach() {
Expand Down
25 changes: 2 additions & 23 deletions engines/bagel/baglib/bagel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,12 @@

namespace Bagel {

// Static member variables.
static unsigned stringHashFunction(const CBofString &s) {
return s.hash();
}
CBofVHashTable<CBofString, HASH_TABLE_SIZE> *CBagel::_cacheFileList;

// Initialize global variables.
//
CBofWindow *g_hackWindow;

CBagel::CBagel(const BagelReg *gameReg) {
assert(gameReg != nullptr);
_cacheFileList = new CBofVHashTable<CBofString, HASH_TABLE_SIZE>(&stringHashFunction);

registerGame(gameReg);
}
Expand All @@ -58,10 +51,6 @@ CBagel::~CBagel() {
// Release options file
release();

// Empty the file cache.
delete _cacheFileList;
_cacheFileList = nullptr;

_szAppName[0] = '\0';
_pMainWnd = nullptr;
_gameReg = nullptr;
Expand Down Expand Up @@ -149,9 +138,6 @@ ErrorCode CBagel::initialize() {
// Initialize local game paths
initLocalFilePaths();

// Check for adequate system resources
verifyRequirements();

// Child class must instantiate the Main Window
return _errCode;
}
Expand Down Expand Up @@ -199,7 +185,7 @@ ErrorCode CBagel::verifyCDInDrive(int diskId, const char *waveFile) {
Common::sprintf_s(szBuf, "$SBARDIR%sDISK%d", PATH_DELIMETER, diskId);

CBofString cString(szBuf, MAX_DIRPATH);
MACROREPLACE(cString);
fixPathName(cString);

// If the disk is not in drive, then inform the user
int i = 0;
Expand Down Expand Up @@ -229,14 +215,7 @@ ErrorCode CBagel::verifyCDInDrive(int diskId, const char *waveFile) {
return _errCode;
}

ErrorCode CBagel::verifyRequirements() {
assert(isValidObject(this));
assert(_gameReg != nullptr);

return _errCode;
}

void MACROREPLACE(CBofString &s) {
void fixPathName(CBofString &s) {
// Remove any homedir prefix. In ScummVM, all paths are relative
// to the game folder automatically
char *p = strstr(s.getBuffer(), HOMEDIR_TOKEN);
Expand Down
9 changes: 1 addition & 8 deletions engines/bagel/baglib/bagel.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ namespace Bagel {
// Defines default chroma color to be palette index 1
#define DEFAULT_CHROMA_COLOR 1

extern void MACROREPLACE(CBofString &s);
extern void fixPathName(CBofString &s);

class CBagMasterWin;

Expand Down Expand Up @@ -187,13 +187,6 @@ class CBagel : public CBofOptions, public CBofApp {
*/
ErrorCode initLocalFilePaths();

/**
* Checks system resources, determining if user has the minimum
* system requirements to play this game.
* @return Error return code
*/
ErrorCode verifyRequirements();

// Data members
const BagelReg *_gameReg = nullptr;

Expand Down
8 changes: 4 additions & 4 deletions engines/bagel/baglib/base_pda.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@ class SBBasePda {
static PdaMode getPdaMode() {
return _pdaMode;
}
bool isActivated() {
bool isActivated() const {
return _activating ? !_activated : _activated;
}
bool isActivating() {
bool isActivating() const {
return _activating;
}

Expand Down Expand Up @@ -139,7 +139,7 @@ class SBBasePda {
_deactivateFl = b;
}

bool getDeactivate() {
bool getDeactivate() const {
return _deactivateFl;
}

Expand Down Expand Up @@ -184,7 +184,7 @@ class SBBasePda {
void setZoomed(bool newVal) {
_zoomedFl = newVal;
}
bool getZoomed() {
bool getZoomed() const {
return _zoomedFl;
}

Expand Down
2 changes: 1 addition & 1 deletion engines/bagel/baglib/bmp_object.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class CBagBmpObject : public CBagObject {

bool isInside(const CBofPoint &pt) override;

CBofBitmap *getBitmap() {
CBofBitmap *getBitmap() const {
return _bmp;
}
CBofRect getRect() override;
Expand Down
4 changes: 2 additions & 2 deletions engines/bagel/baglib/button_object.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class CBagButtonObject : public CBagSpriteObject {
ErrorCode attach() override;
ErrorCode detach() override;

BUTTON_TYPE getButtonType() {
BUTTON_TYPE getButtonType() const {
return _buttonType;
}

Expand All @@ -94,7 +94,7 @@ class CBagButtonObject : public CBagSpriteObject {
return _callbackFct;
}

void *getCallBackInfo() {
void *getCallBackInfo() const {
return _callbackInfo;
}

Expand Down
12 changes: 6 additions & 6 deletions engines/bagel/baglib/command_object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ bool CBagCommandObject::runObject() {
} else if (getFileName() == "ENTRYTHUD") { // Thud
CBofRect tmpRect(60, 50, 137, 70);
CBofString bmpName("$SBARDIR\\GENERAL\\POPUP\\THUDPOP.BMP");
MACROREPLACE(bmpName);
fixPathName(bmpName);
CDevDlg dlg;
dlg.create(bmpName, CBagel::getBagApp()->getMasterWnd(), CBofApp::getApp()->getPalette(), &tmpRect);
dlg.doModal();
Expand All @@ -270,7 +270,7 @@ bool CBagCommandObject::runObject() {
} else if (getFileName() == "ENTRYFLEE") { // Fleebix
CBofRect tmpRect(35, 48, 114, 69);
CBofString bmpName("$SBARDIR\\GENERAL\\POPUP\\FLEEDAT.BMP");
MACROREPLACE(bmpName);
fixPathName(bmpName);
CDevDlg dlg;
dlg.create(bmpName, CBagel::getBagApp()->getMasterWnd(), CBofApp::getApp()->getPalette(), &tmpRect);
dlg.doModal();
Expand All @@ -279,7 +279,7 @@ bool CBagCommandObject::runObject() {
} else if (getFileName() == "ENTRYCLICK") { // Click's locker combo
CBofRect tmpRect(60, 49, 138, 68);
CBofString bmpName("$SBARDIR\\GENERAL\\POPUP\\CLICKPOP.BMP");
MACROREPLACE(bmpName);
fixPathName(bmpName);
CDevDlg dlg;
dlg.create(bmpName, CBagel::getBagApp()->getMasterWnd(), CBofApp::getApp()->getPalette(), &tmpRect);
dlg.doModal();
Expand All @@ -288,7 +288,7 @@ bool CBagCommandObject::runObject() {
} else if (getFileName() == "ENTRYFRUIT") { // MegaWave the fruit
CBofRect tmpRect(35, 49, 114, 68);
CBofString bmpName("$SBARDIR\\GENERAL\\POPUP\\CLICKDAT.BMP");
MACROREPLACE(bmpName);
fixPathName(bmpName);
CDevDlg dlg;
dlg.create(bmpName, CBagel::getBagApp()->getMasterWnd(), CBofApp::getApp()->getPalette(), &tmpRect);
dlg.doModal();
Expand All @@ -297,7 +297,7 @@ bool CBagCommandObject::runObject() {
} else if (getFileName() == "D7CODE1DLG") { // Deven-7 code word
CBofRect tmpRect(10, 48, 189, 69);
CBofString bmpName("$SBARDIR\\GENERAL\\POPUP\\DEVENPOP.BMP");
MACROREPLACE(bmpName);
fixPathName(bmpName);
CDevDlg dlg;
dlg.create(bmpName, CBagel::getBagApp()->getMasterWnd(), CBofApp::getApp()->getPalette(), &tmpRect, true);
dlg.doModal();
Expand Down Expand Up @@ -364,7 +364,7 @@ bool CBagCommandObject::runObject() {
g_allowPaintFl = false;

CBofString smkName("$SBARDIR\\BAR\\EVGAMWIN.SMK");
MACROREPLACE(smkName);
fixPathName(smkName);

// Play the movie only if it exists
if (fileExists(smkName.getBuffer())) {
Expand Down
6 changes: 3 additions & 3 deletions engines/bagel/baglib/fmovie.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ namespace Bagel {

class CBagFMovie : public CBofDialog {
public:
enum MVSTATUS { MOVIE_STOPPED, MOVIE_PAUSED, MOVIE_FOREWARD, MOVIE_REVERSE };
enum MovieStatus { MOVIE_STOPPED, MOVIE_PAUSED, MOVIE_FOREWARD, MOVIE_REVERSE };

protected:
Video::SmackerDecoder *_smk;

bool _escCanStopFl;
bool _loopFl;
MVSTATUS _movieStatus;
MovieStatus _movieStatus;

CBofBitmap *_bmpBuf;
CBofBitmap *_filterBmp;
Expand Down Expand Up @@ -116,7 +116,7 @@ class CBagFMovie : public CBofDialog {
virtual bool pause();
virtual bool stop();

virtual MVSTATUS status() {
virtual MovieStatus status() {
return _movieStatus;
}

Expand Down
2 changes: 1 addition & 1 deletion engines/bagel/baglib/log_msg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ ErrorCode CBagLog::playMsgQueue() {
CBofString smkName(localBuffer, 256);

smkName = OVERRIDE_SMK;
MACROREPLACE(smkName);
fixPathName(smkName);

CBagMovieObject *pMovie = (CBagMovieObject *)getObject(OVERRIDE_MOVIE);
if (pMovie) {
Expand Down
24 changes: 12 additions & 12 deletions engines/bagel/baglib/master_win.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,11 @@ CBagMasterWin::CBagMasterWin() {

// Assume default system screen
_sysScreen = "$SBARDIR\\GENERAL\\SYSTEM\\GAMBHALL.BMP";
MACROREPLACE(_sysScreen);
fixPathName(_sysScreen);

// Load wait sound for when user hits the spacebar
CBofString waitName("$SBARDIR\\GENERAL\\WAIT.WAV");
MACROREPLACE(waitName);
fixPathName(waitName);

_waitSound = new CBofSound(this, waitName, SOUND_MIX);
}
Expand Down Expand Up @@ -311,7 +311,7 @@ ErrorCode CBagMasterWin::newGame() {
app->getOption("Startup", "WLDFile", workStr, STARTWORLD, 255);

initWld = workStr;
MACROREPLACE(initWld);
fixPathName(initWld);
}

loadGlobalVars(GLOBALWORLD);
Expand All @@ -337,7 +337,7 @@ ErrorCode CBagMasterWin::loadFile(const CBofString &wldName, const CBofString &s

if (!paintedFl) {
paintedFl = true;
MACROREPLACE(wldFileName);
fixPathName(wldFileName);
CBofRect cRect;
cRect.left = (640 - 520) / 2;
cRect.top = (480 - 240) / 2;
Expand Down Expand Up @@ -417,7 +417,7 @@ ErrorCode CBagMasterWin::loadFile(const CBofString &wldName, const CBofString &s
}
_gameSDevList = new CBofList<CBagStorageDev *>;

MACROREPLACE(wldFileName);
fixPathName(wldFileName);

timerStart();

Expand Down Expand Up @@ -565,7 +565,7 @@ ErrorCode CBagMasterWin::loadGlobalVars(const CBofString &wldName) {

if (_variableList != nullptr) {

MACROREPLACE(wldFileName);
fixPathName(wldFileName);

if (fileExists(wldFileName) && (fileLength(wldFileName) > 0)) {
// Force buffer to be big enough so that the entire script
Expand Down Expand Up @@ -768,7 +768,7 @@ ErrorCode CBagMasterWin::loadFileFromStream(CBagIfstream &input, const CBofStrin
input.eatWhite();

getAlphaNumFromStream(input, str);
MACROREPLACE(str);
fixPathName(str);

// Specify if we have a shared palette or not, look for
// the USESHAREDPAL token after the full cursor specification
Expand Down Expand Up @@ -846,7 +846,7 @@ ErrorCode CBagMasterWin::loadFileFromStream(CBagIfstream &input, const CBofStrin
input.eatWhite();

getAlphaNumFromStream(input, bmpFileName);
MACROREPLACE(bmpFileName);
fixPathName(bmpFileName);

// Read the palette in and keep it hanging around for later use
CBofPalette::setSharedPalette(bmpFileName);
Expand All @@ -864,7 +864,7 @@ ErrorCode CBagMasterWin::loadFileFromStream(CBagIfstream &input, const CBofStrin
input.eatWhite();

getAlphaNumFromStream(input, _sysScreen);
MACROREPLACE(_sysScreen);
fixPathName(_sysScreen);

logInfo(buildString("SYSSCREEN = %s", _sysScreen.getBuffer()));
}
Expand All @@ -883,7 +883,7 @@ ErrorCode CBagMasterWin::loadFileFromStream(CBagIfstream &input, const CBofStrin
input.eatWhite();

getAlphaNumFromStream(input, _cdChangeAudio);
MACROREPLACE(_cdChangeAudio);
fixPathName(_cdChangeAudio);

logInfo(buildString("DISKAUDIO = %s", _cdChangeAudio.getBuffer()));
}
Expand Down Expand Up @@ -993,15 +993,15 @@ ErrorCode CBagMasterWin::onHelp(const CBofString &helpFile, bool /*bSaveBkg*/, C
CBofString fileName(localBuffer, 256);

fileName = helpFile;
MACROREPLACE(fileName);
fixPathName(fileName);

// use specified bitmap as this dialog's image
char backGroundBuffer[256];
backGroundBuffer[0] = '\0';
CBofString backGround(backGroundBuffer, 256);

backGround = buildString("$SBARDIR%sGENERAL%sRULES%sHELPSCRN.BMP", PATH_DELIMETER, PATH_DELIMETER, PATH_DELIMETER);
MACROREPLACE(backGround);
fixPathName(backGround);

CBofBitmap *bmp = Bagel::loadBitmap(backGround);
CBagHelp help;
Expand Down
10 changes: 5 additions & 5 deletions engines/bagel/baglib/master_win.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,23 +154,23 @@ class CBagMasterWin : public CBofWindow, public CBagParseObject {
ErrorCode setStorageDev(const CBofString &wldName, bool entry = true);
ErrorCode gotoNewWindow(const CBofString *str);

uint16 getDiskID() {
uint16 getDiskID() const {
return _diskId;
}
void setDiskID(uint16 id) {
_diskId = id;
}

CBofWindow *getCurrentGameWindow() {
CBofWindow *getCurrentGameWindow() const {
return (CBofWindow *)_gameWindow;
}
CBagStorageDevWnd *getCurrentStorageDev() {
CBagStorageDevWnd *getCurrentStorageDev() const {
return _gameWindow;
}
CBagStorageDevManager *getStorageDevManager() {
CBagStorageDevManager *getStorageDevManager() const {
return _storageDeviceList;
}
CBagVarManager *getVariableManager() {
CBagVarManager *getVariableManager() const {
return _variableList;
}

Expand Down
2 changes: 1 addition & 1 deletion engines/bagel/baglib/menu_dlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ bool CBagMenu::trackPopupMenu(uint32 /*nFlags*/, int x, int y, CBofWindow *pWnd,
char szBuf[256];
Common::strcpy_s(szBuf, EXAMINEBMP);
CBofString cString(szBuf, 256);
MACROREPLACE(cString);
fixPathName(cString);
CBofPalette xPal;

xPal.loadPalette(cString);
Expand Down
1 change: 0 additions & 1 deletion engines/bagel/baglib/menu_dlg.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ class CBagMenu : public CBagStorageDev {

bool trackPopupMenu(uint32 nFlags, int x, int y, CBofWindow *pWnd, CBofPalette *pPal, CBofRect *lpRect = 0);

// bool AddUniversalObject(CBagObject *pObj);
static bool removeUniversalObjectList();
static bool setUniversalObjectList(CBofList<CBagObject *> *pObjList);
static CBofList<CBagObject *> *getUniversalObjectList() {
Expand Down

0 comments on commit a8f77dd

Please sign in to comment.